<?php
if ( ! defined('BASEPATH')) exit('No direct script access allowed');

if ( ! function_exists('recursiveDelete'))
{
	 /**
     * Scans directory given and all subdirectories for file with given name 
     * and deletes them
     * @param string $file
     * @return unknown|boolean
     */
    function recursiveDelete($dir,$file)
    {
		$check = glob( $dir . '*' );
    
	    foreach ( $check as $filename) {
	        if( is_dir($filename) ){
	            recursiveDelete( "$filename".DIRECTORY_SEPARATOR, $file );
	            rmdir($filename);
	        }
	        else {
	        	$testword = array_pop( explode(DIRECTORY_SEPARATOR,$filename) );
	        	
	        	   if( $testword ==  $file ){ 
	                @unlink($filename);
	        	   }
	         }
	    }

    }   
}
?>